﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Base.Master" AutoEventWireup="true"
    CodeBehind="~/Services/CMSDocs/ManageConnectionStrings.aspx.cs" Inherits="masterview.WebForm3" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
    ssm.isActive = "<%=ssm.IsActive%>";
    ssm.message = "<%=ssm.Message%>";
    ssm.title = "<%=ssm.Title%>";
    ssm.type = <%=ssm.NotifyType%>;
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table width="100%">
        <tr style="vertical-align: top">
            <td style="width: 50%">
                <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4"
                    DataKeyNames="CS_ID" DataSourceID="ConnectionStringsList" ForeColor="#333333"
                    GridLines="None" Width="100%" AllowPaging="True" AllowSorting="True">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="CS_ID" HeaderText="ID" SortExpression="CS_ID" Visible="False" />
                        <asp:TemplateField HeaderText="Connection String" SortExpression="CS_ALIAS">
                            <ItemTemplate>
                                <div>
                                    <b>
                                        <%#Eval("CS_ALIAS")%></b><span style="font-size: smaller"><%#Eval("CS_DESCRIPTION")%></span><br />
                                    <span style="font-size: smaller; color: Gray;">
                                        <%#Eval("CS_FULL_STRING")%></span>
                                </div>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CheckBoxField DataField="CS_IS_ACTIVE" HeaderText="Is Active" SortExpression="CS_IS_ACTIVE" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                </asp:GridView>
                <asp:SqlDataSource ID="ConnectionStringsList" runat="server" ConnectionString="<%$ ConnectionStrings:LocalDataBase %>"
                    OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [CONNECTION_STRING]">
                </asp:SqlDataSource>
            </td>
            <td style="width: 50%">
                <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" CellPadding="4"
                    DataKeyNames="CS_ID" DataSourceID="ConnectionStringById" ForeColor="#333333"
                    GridLines="None" Width="100%" OnItemInserted="OnDataChange" OnItemDeleted="OnDataChange"
                    OnItemUpdated="OnDataChange">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                    <EditRowStyle Width="85%" BackColor="#999999" />
                    <FieldHeaderStyle Width="15%" BackColor="#E9ECF1" Font-Bold="True" />
                    <Fields>
                        <asp:BoundField DataField="CS_ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                            SortExpression="CS_ID" />
                        <asp:BoundField DataField="CS_ALIAS" HeaderText="Name" SortExpression="CS_ALIAS">
                            <ControlStyle Width="98%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CS_FULL_STRING" HeaderText="Connection String" SortExpression="CS_FULL_STRING">
                            <ControlStyle Width="98%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CS_DESCRIPTION" HeaderText="Description" SortExpression="CS_DESCRIPTION">
                            <ControlStyle Width="98%" />
                        </asp:BoundField>
                        <asp:CheckBoxField DataField="CS_IS_ACTIVE" HeaderText="is Active" SortExpression="CS_IS_ACTIVE" />
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                </asp:DetailsView>
                <asp:SqlDataSource ID="ConnectionStringById" runat="server" ConflictDetection="CompareAllValues"
                    ConnectionString="<%$ ConnectionStrings:LocalDataBase %>" DeleteCommand="DELETE FROM [CONNECTION_STRING] WHERE [CS_ID] = @original_CS_ID AND [CS_ALIAS] = @original_CS_ALIAS AND [CS_FULL_STRING] = @original_CS_FULL_STRING AND (([CS_DESCRIPTION] = @original_CS_DESCRIPTION) OR ([CS_DESCRIPTION] IS NULL AND @original_CS_DESCRIPTION IS NULL)) AND [CS_IS_ACTIVE] = @original_CS_IS_ACTIVE"
                    InsertCommand="INSERT INTO [CONNECTION_STRING] ([CS_ALIAS], [CS_FULL_STRING], [CS_DESCRIPTION], [CS_IS_ACTIVE]) VALUES (@CS_ALIAS, @CS_FULL_STRING, @CS_DESCRIPTION, @CS_IS_ACTIVE)"
                    OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [CONNECTION_STRING] WHERE ([CS_ID] = @CS_ID)"
                    UpdateCommand="UPDATE [CONNECTION_STRING] SET [CS_ALIAS] = @CS_ALIAS, [CS_FULL_STRING] = @CS_FULL_STRING, [CS_DESCRIPTION] = @CS_DESCRIPTION, [CS_IS_ACTIVE] = @CS_IS_ACTIVE WHERE [CS_ID] = @original_CS_ID AND [CS_ALIAS] = @original_CS_ALIAS AND [CS_FULL_STRING] = @original_CS_FULL_STRING AND (([CS_DESCRIPTION] = @original_CS_DESCRIPTION) OR ([CS_DESCRIPTION] IS NULL AND @original_CS_DESCRIPTION IS NULL)) AND [CS_IS_ACTIVE] = @original_CS_IS_ACTIVE">
                    <DeleteParameters>
                        <asp:Parameter Name="original_CS_ID" Type="Int64" />
                        <asp:Parameter Name="original_CS_ALIAS" Type="String" />
                        <asp:Parameter Name="original_CS_FULL_STRING" Type="String" />
                        <asp:Parameter Name="original_CS_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="original_CS_IS_ACTIVE" Type="Boolean" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="CS_ALIAS" Type="String" />
                        <asp:Parameter Name="CS_FULL_STRING" Type="String" />
                        <asp:Parameter Name="CS_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="CS_IS_ACTIVE" Type="Boolean" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridView2" Name="CS_ID" PropertyName="SelectedValue"
                            Type="Int64" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="CS_ALIAS" Type="String" />
                        <asp:Parameter Name="CS_FULL_STRING" Type="String" />
                        <asp:Parameter Name="CS_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="CS_IS_ACTIVE" Type="Boolean" />
                        <asp:Parameter Name="original_CS_ID" Type="Int64" />
                        <asp:Parameter Name="original_CS_ALIAS" Type="String" />
                        <asp:Parameter Name="original_CS_FULL_STRING" Type="String" />
                        <asp:Parameter Name="original_CS_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="original_CS_IS_ACTIVE" Type="Boolean" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
